package Qz54;

import java.util.ArrayList;

/**
 * 遍历二叉树
 */
public class Test {
    public static void main(String[] args) {

    }
}


 class Solution22 {
    public ArrayList<Integer> PrintFromTopToBottom(TreeNode root) {
        ArrayList<Integer> res = new ArrayList<>();
        if(root == null){
            return res;
        }
        heler(root, res);
        return res;
    }
    public void heler(TreeNode root, ArrayList<Integer> res){
        if(root == null){
            return;
        }
        heler(root.left, res);
        res.add(root.val);
        heler(root.right, res);
    }
}